package API;

import java.util.Random;
import java.util.Scanner;
import java.lang.String;

public class demo {

    //    public static voidi main(String[] args) {
//        Integer i1 = 129;
//        Integer i2 = 129;
//        System.out.println(i1);
//        System.out.println(i2);
//    }
    public static void main(String[] args) {


        while (true) {
            Random random = new Random();
            char[] arr = new char[5];

            for (int i = 0; i < 5; i++) {
                Random random1 = new Random();

                switch (random.nextInt(2)) {
                    case 0:
                        arr[i] = (char) (random1.nextInt(9) + 48);
                        break;
                    case 1:
                        arr[i] = (char) (random1.nextInt(26) + 65);
                        break;
                    case 2:
                        arr[i] = (char) (random1.nextInt(26) + 97);
                        break;
                }
            }
            System.out.println(arr);
            System.out.println("请输入验证码");
            Scanner scanner = new Scanner(System.in);
            String s = new String(arr);
            if (scanner.nextLine().equalsIgnoreCase(s)) {
                System.out.println("验证码正确");
                break;
            } else {
                System.out.println("验证码错误");
            }
        }


    }
}
